CREATE OR REPLACE PACKAGE BODY ut_pck_relation
IS
   PROCEDURE ut_setup IS
   BEGIN
     null;
   END;
 
   PROCEDURE ut_teardown
   IS
   BEGIN
     null;
   END;
     PROCEDURE ut_appendComposition_key_test
	 is
	 v_root_elm number := pck_element.getElm_IdByBookmark('root');
	 v_new_elm_id number := pck_element.createElement('new elm',null,pck_meta.getScm_IdByName('Container','/omscube'),1);
	 v_relation_id number;
	 p_key varchar(400) := 'my key';
	 v_compare_key varchar(400);
	 begin
	 	  savepoint A;
	 	  v_relation_id := pck_relation.appendComposition (v_root_elm,pck_meta.getCat_IdByName('containers','Container','/omscube'),v_new_elm_id,null,1);
		  select cmp_key into v_compare_key from composition where cmp_id = v_relation_id;
		  utp.utAssert.isnotnull('key is not null',v_compare_key);
		  rollback to A;
	 	  savepoint B;
		  v_relation_id := pck_relation.appendComposition (v_root_elm,pck_meta.getCat_IdByName('containers','Container','/omscube'),v_new_elm_id,p_key,1);
		  select cmp_key into v_compare_key from composition where cmp_id = v_relation_id;  
		  utp.utAssert.eq('key is setted', p_key,v_compare_key);
  		  rollback to B;
	 end;
   PROCEDURE ut_insertCompositionBefore
   is begin
   null;
   end;
   PROCEDURE ut_appendAssociation_key_test
   is 
   	 v_alias_elm number := pck_element.getElm_IdByBookmark('alias');
	 v_new_elm_id number := pck_element.createElement('new elm',null,pck_meta.getScm_IdByName('Container','/omscube'),1);
 	 v_relation_id number;
	 p_key varchar(400) := 'my key';
	 v_compare_key varchar(400);
   Begin
   		 savepoint A;
   		v_relation_id := pck_relation.appendAssociation( v_alias_elm, pck_meta.getCat_IdByName('targets','Alias','/omscube'),v_new_elm_id,null,1);
		 select ass_key into v_compare_key from association where ass_id = v_relation_id;
		 utp.utAssert.isnotnull('key is not null',v_compare_key);
		 rollback to A;

		 savepoint B;
   		v_relation_id := pck_relation.appendAssociation( v_alias_elm, pck_meta.getCat_IdByName('targets','Alias','/omscube'),v_new_elm_id,p_key,1);
		 select ass_key into v_compare_key from association where ass_id = v_relation_id;
		  utp.utAssert.eq('key is setted', p_key,v_compare_key);
		  
		 rollback to B;

   end;
  END;
/
